<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.menggudf.model.SystemAdminModel" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	SystemAdminModel m=(SystemAdminModel)request.getSession().getAttribute("SystemAdminModel");
	String name = request.getSession().getAttribute("SystemAdminModel")==null ? "":m.getAdminName();
	String adminCode = request.getSession().getAttribute("SystemAdminModel")==null ? "":m.getAdminCode();
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" > 

<html>
<head>
<script src="./js/bootstrap-jquery-plugin/jquery.bootstrap.js"></script>
<script type="text/javascript" src="./js/jquery.complexify.js"></script>
<script type="text/javascript" src="./js/xss.js"></script>
<link rel="icon" href="./images/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="./images/favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="./css/head.css">
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation" id="head-nav">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a href="./jsp/login.jsp">
      	  <img src="images/menggulg.png" style="    display: inline-block;border-radius: 5px;height: 30px;margin-left: 30px;margin-top: 10px;"/>
      </a>
    </div>
    <ul class="nav navbar-top-links navbar-right">
    	<li>
    		<span>欢迎</span>
			<a id="user"><%=name %></a>
    	</li>
    	<li>
    		<a class="loginout">
    			<i class="fa fa-power-off fa-lg"></i>
    			<span>退出</span>
    		</a>
    	</li>
    </ul>
</nav>
 <div id="pwwrap" style="display:none">
	<form id="loginform" role="form" class="form-inline"  name="changepwd">
		<div class="form-group">
			<label for="txtOldPass" class="col-sm-7 control-label">旧的密码：</label>
			<div class="col-sm-5">
		  		<input type="password" class="form-control" id="txtOldPass" placeholder="请输入原密码" onKeyUp="filters(this)" onChange="filters(this)">
	  		</div>
		</div>
		<div class="form-group">
			<label for="txtNewPass" class="col-sm-7	 control-label">新的密码：</label>
			<div class="col-sm-5">
			  	<input type="password" class="form-control" id="txtNewPass" placeholder="密码长度不少于6" onKeyUp="filters(this)" onChange="filters(this)">
		  	</div>
		</div>
		<div class="form-group">
			<label for="txtRePass" class="col-sm-7 control-label">确认密码：</label>
		  	<div class="col-sm-5">
		  		<input type="password" class="form-control" id="txtRePass" placeholder="密码长度不少于6" onKeyUp="filters(this)" onChange="filters(this)">
	  		</div>
		</div>
	</form>
</div>
<script type="text/javascript">

$(function() {
	"use strict";
	
	if($("#user").text()==""){
		window.location.href="<%=basePath%>";
	}
	
	$(".loginout").on('click', function() {
		$.messager.model = { 
        ok:{ text: "确定", classed: 'btn-success' },
        cancel: { text: "取消", classed: 'btn-error' }
      };
      	$.messager.confirm("温馨提示：", "您确定要退出本次登录吗?!", function() { 
        	$.ajax({
                   url: "./sysAdimn/loginout.spring",
                   data: {
                   
                   },
                   type: "POST",
                   dataType: 'json',
                   cache: false,
                   success: function (ret) {
                       if(ret.resultCode==0){
                       		window.location.href="<%=basePath%>";
                       }
                   }
               });
      	});
	});
	
    $("#user").on('click', function() {
	   	$("#pwwrap").show();
		$("#pwwrap").dialog({
	         	title   : "修改密码",
	        	'class' :  "mydialog",
	        	onClose : function() {
        			$("#txtOldPass").val('');
             		$("#txtNewPass").val('');
             		$("#txtRePass").val(''); 
	         		$(this).dialog("close");
	          	}, 
	          	buttons : [{
	          		text : "提交",
	          		'class' : "btn btn-primary",
	             	click : function() {
	             		var txtOldPass = $("#txtOldPass").val();
	             		var txtNewPass = $("#txtNewPass").val();
	             		var txtRePass = $("#txtRePass").val();
	             		if(txtNewPass!=txtNewPass){
	             			$.messager.popup("两次新密码输入不相同,请重新输入！");
	             		}else{
		                    $.ajax({
		                     	url: "./sysAdimn/editPwd",
			                     data: {
									pwd:txtNewPass,
									oldPwd :txtOldPass
			                     },
			                     type: "POST",
			                     dataType: 'json',
			                     cache: false,
			                     success: function (ret) {
									$.messager.popup(ret.msg);
			                     }
			                 });
		                }
           	            $("#txtOldPass").val('');
	             		$("#txtNewPass").val('');
	             		$("#txtRePass").val(''); 
		                $(this).dialog("close");
	             		}
	             },{
	             text : "关闭",
	             'class' : "btn btn-default",
	             click : function() {
	                    $("#txtOldPass").val('');
	             		$("#txtNewPass").val('');
	             		$("#txtRePass").val(''); 
	                	$(this).dialog("close");
             	}
	         }]
	     });

    });
	
});


</script>
</body>
</html>